import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import federation from "@originjs/vite-plugin-federation";
import path from "node:path";

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: { "@": path.resolve(__dirname, "src") },
  },
  plugins: [
    react(),
    federation({
      name: "remote",
      filename: "remoteEntry.js",
      exposes: {
        "./Button": "./src/components/Button",
      },
      // 避免重复依赖
      // 本地模块和远程模块共享的依赖，可根据需要调整。
      // 本地模块需配置所有使用到的远端模块的依赖。
      // 远端模块需要配置对外提供的组件的依赖。
      shared: ["react", "react-dom"],
    }),
  ],
  preview: {
    host: "0.0.0.0",
    port: 5001,
  },
  server: {
    host: "0.0.0.0",
    port: 5001,
  },
  build: {
    target: "esnext",
    minify: true,
    assetsInlineLimit: 4096,

    modulePreload: false,
    cssCodeSplit: false,
  },
});
